/**
 * @description:
 * @author:Mr.Cat
 * @create:2021-10-01 21:26
 **/
/*//方式一：自定义枚举类
class Season {

    //声明Season对象的属性：private final修饰
    private final String seasonName;
    private final String seasonDesc;


    //2、私有化类的构造其，并给对象的属性赋值
    private Season(String seasonName, String seasonDesc) {
        this.seasonDesc = seasonDesc;
        this.seasonName = seasonName;
    }

    //3、提供当前枚举类的多个对象：public static final
    public static final Season SPRINT = new Season("春天", "春暖花开");
    public static final Season SUMMER = new Season("夏天", "夏日炎炎");
    public static final Season AUTUMN = new Season("秋天", "秋高气爽");
    public static final Season WINTER = new Season("冬天", "白雪皑皑");

    //4、其它诉求：获取枚举类对象的属性
    public String getSeasonName() {
        return seasonName;
    }

    public String getSeasonDesc() {
        return seasonDesc;
    }

    //5、提供toString

    @Override
    public String toString() {
        return "Season{" +
                "seasonName='" + seasonName + '\'' +
                ", seasonDesc='" + seasonDesc + '\'' +
                '}';
    }
}*/
public class SeasonTest1 {
    public static void main(String[] args) {
        Season1 summer = Season1.SUMMER;
        System.out.println(summer);
        System.out.println(Season1.class.getSuperclass());
        System.out.println(summer.toString());

        //values()
        Season1[] values = Season1.values();
        for(int i=0;i<values.length;i++){
            System.out.println(values[i]);
        }

        //valueOf(String objName):返回枚举类中对象名是objName的对象
        //如果没有objName的枚举类对象，则抛异常：IllegalArgumentException
        Season1 winter = Season1.valueOf("WINTER");
//        Season1 winter =Season1.valueOf("WINTER1");
        System.out.println(winter);
    }
}

//方式二：使用enum关键字定义枚举类
/*说明：定义的枚举类默认继承于java.lang.Enum类
在Enum重写的toString是输出：当前枚举类对象的名称
* */
enum Season1 implements test1 {

    //1、提供当前枚举类的多个对象,多个对象之间用","隔开，最后一个用";"
    SPRINT("春天", "春暖花开"){
        @Override
        public void show() {
            System.out.println("这是春天");
        }
    },
    SUMMER("夏天", "夏日炎炎"){
        @Override
        public void show() {
            System.out.println("这是夏天");
        }
    },
    AUTUMN("秋天", "秋高气爽"){
        @Override
        public void show() {
            System.out.println("这是秋天");
        }
    },
    WINTER("冬天", "白雪皑皑"){
        @Override
        public void show() {
            System.out.println("这是冬天");
        }
    };
    //声明Season对象的属性：private final修饰
    private final String seasonName;
    private final String seasonDesc;


    //2、私有化类的构造其，并给对象的属性赋值
    private Season1(String seasonName, String seasonDesc) {
        this.seasonDesc = seasonDesc;
        this.seasonName = seasonName;
    }


    //3、其它诉求：获取枚举类对象的属性
    public String getSeasonName() {
        return seasonName;
    }

    public String getSeasonDesc() {
        return seasonDesc;
    }

//    //5、提供toString
//
//    @Override
//    public String toString() {
//        return "Season{" +
//                "seasonName='" + seasonName + '\'' +
//                ", seasonDesc='" + seasonDesc + '\'' +
//                '}';
//    }
}
interface test1{
    void show();
}


